#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
工厂模式
@author ：chenzf
@date ：2024/4/24 下午2:03 
"""
class Person:
    pass
class Worker(Person):
    pass
class Student(Person):
    pass
class Teacher(Person):
    pass
class PersonFactory:
    def get_person(self, type):
        if type == 'worker':
            return Worker()
        elif type == 'student':
            return Student()
        elif type == 'teacher':
            return Teacher()
        else:
            raise ValueError('type参数错误')
if __name__ == '__main__':
    factory = PersonFactory()
    print(factory.get_person('worker'))
    print(factory.get_person('student'))
    print(factory.get_person('teacher'))
